public class shuzu {       
    public static int[] insert(int a[], int index, int value) {  
        int b[] = new int[a.length + 1];  
        for (int i = 0; i < b.length; i++) {  
            if (i < index - 1) {  
                b[i] = a[i];  
            }  
            if (i == index - 1) {  
                b[i] = value;  
            }  
            if (i > index - 1) {  
                b[i] = a[i - 1];  
            }  
        }  
        return b;  
    }  
 
    public static void printArray(int a[]) {  
        for (int i = 0; i < a.length; i++) {  
            System.out.print(a[i] + " ");  
        }  
        System.out.println();  
    }  
  
    public static int[] delete(int a[], int index) {  
        int b[] = new int[a.length - 1];  
        for (int i = 0; i < b.length; i++) {  
            if (i < index - 1) {  
                b[i] = a[i];  
            } else {  
                b[i] = a[i + 1];  
            }  
        }  
        return b;  
    }    
    public static void main(String args[]) {  
        int[] a = { 1, 2, 3, 4, 5, 6 ,7,8}; 
        int[]b = delete(a, 5);  
        printArray(b); 
     b = insert(a, 4, 5);   
        printArray(b);     
    }  
} 
